<template>
	<view>
		<template v-if="!isdown">
			<view class="" style="height: 120vh;">
				<view class="flexcenter">
					<view class="placeholderimage" style="margin-top: 100rpx;"></view>
				</view>
				<view class="flexcenter margin_top">
					<view class="xiaohei titletext">滑到底部解鎖POS畫面</view>
					<u-icon name="arrow-downward" color="#fbb826" size="18"></u-icon>
				</view>
			</view>
		</template>
		<template v-if="isdown">
			<u-navbar title="Pos點餐" placeholder>
				<view class="xiaohui" slot="left">
					<view class="flexleft" style="padding-right: 30rpx;">
						<view class="margin_right3" @click="backpage">
							<u-icon name="arrow-left" color="#000" size="24"></u-icon>
						</view>
						<view class="flexbetween"
							style="border: 1rpx solid #fbb826; padding: 10rpx 20rpx;border-radius: 10rpx;">
							<input type="text" placeholder="請輸入搜索内容" class="xiaohei" :focus="inputfocus"
								:auto-focus="hy_type==6?true:false" v-model="name" @confirm="init()"
								confirm-type="search" />
							<view class="" @click="jumpurl('/pages/goodsOrder/saomagmpos?pos=1')">
								<u-icon name="scan" color="#fbb826" size="22"></u-icon>
							</view>
						</view>
					</view>
				</view>
				<view class="flexright xiaohui" slot="right">
					<view class="qxbtn margin_right1" @click="kaiqianx">開錢箱</view>
					<view class="qxbtn">折扣</view>
				</view>
			</u-navbar>
			<view class="flexleft" style="align-items: flex-start;">
				<view class="fenleibox ffffff mainpadding" style="width: 20%;padding-right: 0;padding-bottom: 0;">
					<scroll-view scroll-x="true" style="width: 100%;">
						<view class="flexleft margin_top1">
							<view class="flexleft hei_text main_size bold" v-for="(item,index) in topList" :key="index">
								<text class="margin_right1" style="white-space: nowrap;"
									@click="back(item,index)">{{item.name}}</text>
								<view class="arrowright1" v-show="index!=topList.length-1"></view>
							</view>
						</view>
					</scroll-view>
					<scroll-view scroll-y="true" :style="{'height': caozuo_jx==1?'74vh':'84vh'}"
						style="margin-top: 10rpx;">
						<view class="flexleft" style="position: relative;margin-top: 10rpx;" v-for="item in catedata"
							:key="item.id" @click="classLableClick(item)">
							<view class="itemrighttab borderhui hei_text bold" style="width: 80%;font-size: 28rpx;">
								{{item.name}}
							</view>
							<view class="tiebianarrow flexcenter">
								<view class="arrowright2"></view>
							</view>
						</view>
					</scroll-view>
				</view>
				<view class="goodsbox mainpadding2" style="width: 60%;padding: 0 30rpx;">
					<scroll-view scroll-y="true" :style="{'height': caozuo_jx==1?'84vh':'90vh'}"
						@scrolltolower="onReachBottomt">
						<view class="flexleft flex-wrap">
							<view class="flexcenter" style="width: 25%;" v-for="item in list.data" :key="item.id"
								@click="jumpdetail(item.id)">
								<view class="ffffff radius"
									style="width: 98%;padding: 15rpx;background-color: #FBE0EC;margin-top: 5rpx;">
									<view class="hei_text main_size bold sanhang"
										style="height: 110rpx;font-size: 28rpx;">{{item.name}}
									</view>
									<view class="main_size huang_text bold" style="font-size: 20rpx;">
										+{{item.new_price}}</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</view>
				<view class="ffffff mainpadding" style="width: 20%;padding: 0 30rpx 10rpx;">
					<scroll-view scroll-y="true" :style="{'height': caozuo_jx==1?'72vh':'83vh'}">
						<view class="flexleft margin_top" v-for="item in orderlist" :key="item.id">
							<view class="justify_between_column" style="width: 100%;">
								<view class="hei_text main_size bold">{{item.goods_name}}</view>
								<view class="xiaohui margin_top1 flexbetween" v-if="item.wei || item.hei">
									<text>尺寸：{{item.wei}}*{{item.hei}}</text>
									<text>用量：{{item.formulacount}}{{item.size}}</text>
								</view>
								<view class="xiaolan margin_top1"
									v-if="item.spunatdata_text && item.spunatdata_text.length">規格：<text
										class="margin_right1" v-for="(value) in item.spunatdata_text"
										:key="value.spunatid">{{value.spunatname}}*{{value.num}}&nbsp;&nbsp;&nbsp;</text>
								</view>
								<view class="flexbetween margin_top1">
									<view class="main_size huang_text bold">
										+{{item.d_price}}&nbsp;&nbsp;&nbsp;x{{item.num}}
									</view>
									<view class="flexright">
										<view class="xiaohuang margin_right1">${{item.price}}</view>
										<view class="flexright" @click="removeGoods(item.id)">
											<u-icon name="trash" color="#333" size="16"></u-icon>
										</view>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
					<view>
						<view class="flexbetween">
							<view class="leftAllprice flexleft mainpadding ffffff">
								<!-- <view class="hei_text main_size">合計:</view> -->
								<view class="huang_text main_size" v-text="'$'+totalPrice"></view>
							</view>
							<view class="rightsubmit flexcenter mainpadding" style="min-width: 120rpx;"
								@click="shoukuanbtn">
								<view class="hei_text main_size">收款</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 发票输入 -->
			<u-modal :show="fpisshow" title="請輸入發票號碼" confirmColor="#fbb826" confirmText="確定" cancelText="關閉"
				showCancelButton @cancel="fpisshow=false" @confirm="fpconfirm">
				<view class="slot-content">
					<view class="mainpadding">
						<view class="flexbetween"
							style="border: 1rpx solid #fbb826; padding: 10rpx 20rpx;border-radius: 10rpx;">
							<input type="text" placeholder="" class="xiaohei" :focus="fpinputfocus" :auto-focus="true"
								v-model="tbcode" @confirm="fpconfirm" confirm-type="search" />
							<view class="" @click="getCode">
								<u-icon name="scan" color="#fbb826" size="22"></u-icon>
							</view>
						</view>
					</view>
				</view>
			</u-modal>
			<u-popup mode="center" :show="goodsshow" round="10" @close="goodsclose">
				<view class="" style="width: 90vw;" :style="{'height': caozuo_jx==1?'80vh':'90vh'}" v-if="goodsshow">
					<view style="height: 100%;">
						<goodsmodal :goods_id="goods_id" @submitgoods="submitgoods"></goodsmodal>
					</view>
				</view>
			</u-popup>
			<u-popup :show="show" @close="show=false" round="30" mode="center" closeable>
				<view class="">
					<view class="titletext" v-if="appkey && is_sdkfp==0 && opentype!=-1"
						style="position: relative;top: 20rpx;left: 30rpx;">
						<!-- 0紙本，1載具，2統編，3捐贈 -->
						<text>{{returnfptext(opentype)}}</text>
						<text>{{tbcode}}</text>
						<text v-show="opentype==2 && tbmc">【{{tbmc}}】</text>
					</view>
					<view class="mainpadding flexleft" style="align-items: flex-start;">
						<view class="" style="width: 240rpx;">
							<view class="margin_top5">
								<view class="bold hei_text" style="font-size: 32rpx;">總計金額：</view>
								<view class="bold xiaohei" style="font-size: 52rpx;" v-text="totalPrice"></view>
							</view>
							<view class="margin_top">
								<view class="bold hei_text" style="font-size: 32rpx;">應找金額：</view>
								<view class="bold xiaohong" style="font-size: 52rpx;" v-text="zhaoling"></view>
							</view>
							<view class="margin_top sytbox">
								<input type="text" class="sytsrk" placeholder="實收金額" disabled="" v-model="zhifuje" />
							</view>
						</view>
						<view class="margin_right flexleft" style="width: 630rpx;">
							<view class="flexbetween flex-wrap margin_top" style="width: 74%;">
								<view class="itembox flexcenter" v-for="item in numList" :key="item"
									@click="numtap(item)">
									{{item}}
								</view>
								<view class="itembox delitem flexcenter" @click="delnum">DEL</view>
							</view>
							<view class="flexcolumn margin_top" style="width: 26%;">
								<view class="itembox flexcenter" v-for="item in numList2" :key="item"
									@click="numtap(item)">
									{{item}}
								</view>
							</view>
						</view>
						<view class="flexcolumn margin_right">
							<view class="payTypeClass margin_top5 xiaobai" style="background-color: #00a0e9;"
								@click="submit(4)">信用卡
							</view>
							<!-- <view class="payTypeClass margin_top2 xiaobai" style="background-color: #ec7301;" @click="submit(2)">多元支付
							</view> -->
							<view class="payTypeClass margin_top2 xiaobai" style="background-color: #ec7301;"
								@click="dypay">多元支付
							</view>
							<view class="payTypeClass margin_top2 xiaobai" style="background-color: #db0f62;"
								@click="submit(1)">錢包點數
							</view>
							<view class="payTypeClass margin_top2 xiaobai" style="background-color: #a70182;"
								@click="submit(3)">現金支付
							</view>
						</view>
						<view class="flexcolumn ">
							<!-- 全支付 -->
							<!-- <image class="margin_top5"
								src="https://useradmin.opos.tw/uploads/20241014/26dd0dbc6e3f4c8043749885523d6a25.webp"
								style="width: 300rpx;" @click="dypay(1)" mode="widthFix"></image> -->
							<!-- icash -->
							<!-- <image class="margin_top15"
								src="https://useradmin.opos.tw/uploads/20241014/f9028faec74be6ec9b852b0a542e2f39.webp"
								style="width: 300rpx;" @click="dypay(2)" mode="widthFix"></image> -->
							<!-- 悠悠付 -->
							<!-- <image class="margin_top15"
								src="https://useradmin.opos.tw/uploads/20241014/db85e2590b6109813dafa101ceb2faeb.webp"
								style="width: 300rpx;" @click="dypay(3)" mode="widthFix"></image> -->
							<!-- 街口支付 -->
							<image class="margin_top15"
								src="https://useradmin.opos.tw/uploads/20241014/c74d97b01eae257e44aa9d5bade97baf.webp"
								style="width: 300rpx;" @click="dypay(7)" mode="widthFix"></image>
							<!-- line pay -->
							<image class="margin_top15"
								src="https://useradmin.opos.tw/uploads/20241014/877a9ba7a98f75b90a9d49f53f15a858.webp"
								style="width: 300rpx;" @click="dypay(8)" mode="widthFix"></image>
						</view>
					</view>
				</view>
			</u-popup>
			<u-modal :show="dymodalshow" title="請使用掃描器掃描" confirmColor="#fbb826" confirmText="關閉"
				@confirm="dymodalshow=false">
				<view class="slot-content">
					<view class="mainpadding">
						<view class="flexbetween"
							style="border: 1rpx solid #fbb826; padding: 10rpx 20rpx;border-radius: 10rpx;">
							<input type="text" placeholder="" class="xiaohei" :focus="dyinputfocus" :auto-focus="true"
								v-model="dycode" @confirm="dykoukuan" confirm-type="search" />
							<view class="" @click="dysaoma()">
								<u-icon name="scan" color="#fbb826" size="22"></u-icon>
							</view>
						</view>
					</view>
				</view>
			</u-modal>
		</template>
		<fukuanmsg :show="messagefk.fkshow" :paystatus="messagefk.paystatus"></fukuanmsg>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 40,
				list: {
					data: []
				},
				shop_id: "",
				catedata: [],
				topList: [{
					name: "首頁",
					id: 0
				}], //顶部展示列表
				goodsshow: false,
				pid: 0, //当前分类id
				orderlist: [],
				dataAll: {},
				totalPrice: 0,
				show: false,
				numList: [7, 8, 9, 4, 5, 6, 1, 2, 3, "00", 0],
				numList2: [50, 100, 500, 1000],
				zhifuje: "",
				isdown: true,
				totalwtjPrice: 0,
				name: "",
				caozuo_jx: 1, //caozuo_jx=1手機，2平板
				inputfocus: false,
				dymodalshow: false,
				dycode: "",
				dyinputfocus: false,
				goods_list_ids: "",
				hy_type: 0, //行业类型:0=无,1=吃到饱,2=诊所,3=住宿,4=租借,5工程，6超商
				messagefk: {
					fkshow: false,
					paystatus: 1, //1成功，2失败
				},
				fpisshow: false,
				fpinputfocus: false,
				appkey: "",
				is_sdkfp: 0,
				tbcode: "",
				tbmc: "",
				opentype: -1,
				orderly: 0,
				issubmit: false
			}
		},
		computed: {
			zhaoling() {
				let price = Number(this.zhifuje) - Number(this.totalPrice)
				if (price >= 0) {
					return price
				} else {
					return 0
				}
			}
		},
		watch: {
			dymodalshow(newval) {
				if (!newval) {
					this.dycode = ""
				}
			}
		},
		onLoad(options) {
			this.appkey = uni.getStorageSync("appkey")
			this.is_sdkfp = uni.getStorageSync("is_sdkfp")
			uni.$on("returnCode", data => {
				this.tbcode = data
			})
			this.hy_type = uni.getStorageSync("hy_type")
			this.getInfo()
			if (options.type) {
				this.orderType = options.type
				uni.setStorageSync("orderType", this.type)
			}
			if (options.orderly) {
				this.orderly = options.orderly
			}
			if (options.posdc) {
				this.posdc = options.posdc
			}
			this.shop_id = uni.getStorageSync("shop_id")
			this.init()
			this.getCateList()
			this.$nextTick(() => {
				this.scrollToBottom();
			})
			uni.$on("scangoodsid", data => {
				this.jumpdetail(data)
			})
			uni.$on("possacnCode", data => {
				this.dycode = data
				this.dykoukuan()
			})
		},
		onShow() {
			this.getorderInfo()
		},
		onUnload() {
			uni.$off("scangoodsid")
			uni.$off("returnCode")
			uni.$off("possacnCode")
		},
		methods: {
			returnfptext() {
				if (this.opentype == 0) return "紙本"
				if (this.opentype == 1) return "載具："
				if (this.opentype == 2) return "統編："
				if (this.opentype == 3) return "捐贈："
			},
			fpconfirm() {
				// 0紙本，1載具，2統編，3捐贈
				if (this.tbcode == "") { //紙本
					this.opentype = 0
				}
				if (this.tbcode.length == 8) { //統編
					this.opentype = 2
					this.getTt()
				}
				if (this.tbcode.length == 6) { //捐贈
					this.opentype = 3
				}
				if (this.tbcode.includes('/')) { //載具
					this.opentype = 1
				}
				this.fpisshow = false;
				this.show = true
			},
			getTt() {
				if (this.opentype != 2) {
					return false
				}
				this.http.request("/api/user/getTbmc", "GET", {
					tbcode: this.tbcode
				}).then(res => {
					if (res.code == 1) {
						this.tbmc = res.data.tbinfo.name
					}
				})
			},
			shoukuanbtn() {
				if (this.appkey && this.is_sdkfp == 0) {
					this.fpisshow = true
					this.fpinputfocus = true
				} else {
					this.show = true
				}
			},
			getCode() {
				uni.navigateTo({
					url: "/pages/my/getcodetwm"
				})
			},
			backpage() {
				uni.navigateBack(1)
			},
			kaiqianx() {
				this.http.modal('提示', '是否開啓錢箱', true, (resp) => {
					if (resp) {
						this.http.request("/api/ordergoods/openqx", "POST", {
							shop_id: uni.getStorageSync("shop_id"),
						}).then(res => {
							httpRequest.toast(res.msg)
						})
					}
				})
			},
			goodsclose() {
				this.goodsshow = false
				if (this.hy_type == 6) {
					this.inputfocus = true
				}
			},
			getInfo() {
				this.http.request("/api/shop/Shopdeail", "POST", {
					shop_id: uni.getStorageSync("shop_id"),
				}).then(res => {
					uni.setStorageSync("appkey", res.data.appkey)
					uni.setStorageSync("hy_type", res.data.hy_type)
					uni.setStorageSync("opentable_status", res.data.opentable_status)
					uni.setStorageSync("is_sdkfp", res.data.is_sdkfp)
					uni.setStorageSync("is_call_sdkfp", res.data.is_call_sdkfp)
					uni.setStorageSync("is_pos_sdkfp", res.data.is_pos_sdkfp)
					uni.setStorageSync("houtel_type",res.data.houtel_type)
					this.caozuo_jx = res.data.caozuo_jx //caozuo_jx=1手機，2平板
				})
			},
			onReachBottom() {
				this.isdown = true
			},
			scrollToBottom() {
				const query = uni.createSelectorQuery().in(this);
				query.select('#bottom').boundingClientRect(data => {
					if (data) {
						// 使用scrollIntoView滚动到底部元素
						const scrollTop = data.top + this.$el.scrollTop;
						this.$el.scrollTo({
							top: scrollTop,
							behavior: 'smooth'
						});
					}
				}).exec();
			},
			async dypay(val) {
				let arr = []
				this.orderlist.forEach(item => {
					if (item.is_ti == 0) {
						arr.push(item.id)
					}
				})
				if (arr.length == 0) {
					this.http.toast("暫未選擇新增商品，無法提交")
					return false
				}
				this.dymodalshow = true
				this.dyinputfocus = true
				return false
			},
			async dykoukuan() { //掃碼槍或輸入回車扣款
				if (this.issubmit) return
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				let val = 0 //1全支付，2icash支付，3悠悠付，7街口支付，8line pay
				if (this.dycode.substring(0, 2) == 22) val = 7
				if (this.dycode.substring(0, 2) == 38) val = 8
				if (val == 0) {
					httpRequest.toast("付款碼不存在")
					return false
				}
				let arr = []
				this.orderlist.forEach(item => {
					if (item.is_ti == 0) {
						arr.push(item.id)
					}
				})
				this.goods_list_ids = arr.join()
				let data = {
					zhuimoney: this.totalwtjPrice,
					goods_list_ids: arr.join(),
					order_goods_id: uni.getStorageSync("order_goods_id"),
					ly: this.orderly == 1 ? 2 : 1, //如果是预约订單提交的时候,来源传2其他情况传1
					is_scan: 2,
					opentype: this.opentype,
					tbcode: this.appkey && this.opentype != -1 ? this.tbcode : '',
					tbmc: this.appkey && this.opentype != -1 ? this.tbmc : '',
					order_type: 4,
					paytype: val
				}
				if (this.posdc == 1) {
					this.$set(data, "order_attr", 1)
				}
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				this.issubmit = true
				let res1 = await this.http.request('/api/ordergoods/zhuiorderGoods', 'POST', data)
				uni.hideLoading()
				if (res1.code != 1) {
					httpRequest.toast(res.msg)
					this.issubmit = false
					return false
				}
				uni.showLoading({
					mask: true,
					title: "支付中"
				})
				if (this.dycode.substring(0, 2) == 22) { //街口支付
					let res2 = await httpRequest.request("/api/ordergoods/jkoPayScan", "POST", {
						shop_id: uni.getStorageSync("shop_id"),
						id: uni.getStorageSync("order_goods_id"),
						CardToken: this.dycode,
						goods_list_ids: this.goods_list_ids
					})
					uni.hideLoading()
					if (res2.code == 1) {
						this.messagefk = {
							fkshow: true,
							paystatus: 1
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 1
							}
							uni.reLaunch({
								url: "/pages/workbench/tianjiakhxx"
							})
						}, 500)
					} else {
						this.issubmit = false
						this.dycode = ""
						this.dymodalshow = false
						this.dyinputfocus = false
						this.messagefk = {
							fkshow: true,
							paystatus: 2
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 2
							}
							this.dymodalshow = true
							this.dyinputfocus = true
						}, 500)
					}
				}
				if (this.dycode.substring(0, 2) == 38) { //linepay支付
					let res3 = await httpRequest.request("/api/ordergoods/linepayScan", "POST", {
						shop_id: uni.getStorageSync("shop_id"),
						id: uni.getStorageSync("order_goods_id"),
						oneTimeKey: this.dycode,
						goods_list_ids: this.goods_list_ids
					})
					uni.hideLoading()
					if (res3.code == 1) {
						this.messagefk = {
							fkshow: true,
							paystatus: 1
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 1
							}
							uni.reLaunch({
								url: "/pages/workbench/tianjiakhxx"
							})
						}, 500)
					} else {
						this.issubmit = false
						this.dycode = ""
						this.dymodalshow = false
						this.dyinputfocus = false
						this.messagefk = {
							fkshow: true,
							paystatus: 2
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 2
							}
							this.dymodalshow = true
							this.dyinputfocus = true
						}, 500)
					}
				}
			},
			dysaoma() { //掃碼扣款
				uni.navigateTo({
					url: "/pages/pospay/pospay"
				})
			},
			async submit(val) { //提交
				if (this.issubmit) return
				let arr = []
				this.orderlist.forEach(item => {
					if (item.is_ti == 0) {
						arr.push(item.id)
					}
				})
				if (arr.length == 0) {
					this.http.toast("暫未選擇新增商品，無法提交")
					return false
				}
				let data = {
					zhuimoney: this.totalwtjPrice,
					goods_list_ids: arr.join(),
					order_goods_id: uni.getStorageSync("order_goods_id"),
					ly: this.orderly == 1 ? 2 : 1, //如果是预约订單提交的时候,来源传2其他情况传1
					opentype: this.opentype,
					tbcode: this.appkey && this.opentype != -1 ? this.tbcode : '',
					tbmc: this.appkey && this.opentype != -1 ? this.tbmc : '',
					order_type: 4
				}
				if (this.orderly == 0) {
					this.$set(data, "paytype", val)
				}
				if (this.posdc == 1) {
					this.$set(data, "order_attr", 1)
				}
				if (val == 1) { //点数支付走线下功能需要传这个参数
					this.$set(data, "is_scan", 2)
				}
				this.issubmit = true
				let res = await this.http.request('/api/ordergoods/zhuiorderGoods', 'POST', data)
				if (res.code == 1) {
					if (val == 1) { //点数支付走这里
						uni.navigateTo({
							url: "/pages/dianshupay/dianshupay?type=2&id=" + uni.getStorageSync(
								"order_goods_id")
						})
					} else {
						this.http.toast("提交成功")
						setTimeout(() => {
							uni.reLaunch({
								url: "/pages/workbench/tianjiakhxx"
							})
						}, 500)
					}
				} else {
					this.http.toast(res.msg)
					this.issubmit = false
				}
			},
			numtap(item) {
				if (Number(item) == 0 && this.zhifuje == "") {
					return false
				}
				this.zhifuje = this.zhifuje + item
			},
			delnum() {
				let str = this.zhifuje;
				let newStr = str.slice(0, -1);
				this.zhifuje = newStr
				// 输出: Hello Worl
			},
			submitgoods() {
				this.goodsshow = false
				this.topList = [{
					name: "首頁",
					id: 0
				}]
				this.pid = 0
				this.init()
				this.getCateList()
				if (this.hy_type == 6) {
					this.inputfocus = true
				}
				this.getorderInfo()
			},
			async removeGoods(id) { //刪除商品
				this.http.request('/api/ordergoods/delorderGoodslist', 'POST', {
					id
				}).then(res => {
					if (res.code == 1) {
						this.http.toast("刪除成功")
						this.getorderInfo()
					} else {
						this.http.toast(res.msg)
					}
				})
			},
			getorderInfo() { //获取订單详情的商品
				this.http.request('/api/Ordergoods/deailOrdergoods', 'POST', {
					id: uni.getStorageSync("order_goods_id")
				}).then(res => {
					if (res.code == 1) {
						this.orderlist = res.data.goods_data
						this.dataAll = res.data
						this.totalPrice = 0
						this.totalwtjPrice = 0
						if (this.orderlist.length) {
							this.orderlist.forEach(item => {
								this.totalPrice = Number(this.totalPrice) + Number(item.price)
								if (item.is_ti == 0) {
									this.totalwtjPrice = Number(this.totalwtjPrice) + Number(item.price)
								}
							})
						}
					} else {
						this.http.toast(res.msg);
					}
				})
			},
			jumpdetail(id) {
				this.goods_id = id
				this.goodsshow = true
				this.inputfocus = false
				return false
				if (this.orderType == 1) {
					uni.navigateTo({
						url: "/pages/callOutOrder/callGoodsdetail?id=" + id
					})
				} else {
					if (this.orderly == 1) { //預約訂單商品訂單點餐
						uni.navigateTo({
							url: "/pages/yuYueOrder/goodsdetail?id=" + id
						})
					} else { //pos點餐點餐
						uni.navigateTo({
							url: "/pages/callOutOrder/goodsdetail?id=" + id + "&posdc=" + this.posdc
						})
					}
				}
			},
			getCateList() { //分类列表
				let _this = this
				this.http.request('/api/shop/listClass', 'POST', {
					shop_id: this.shop_id, //店鋪id
					id: this.pid
				}).then(res => {
					if (res.code == 1) {
						this.catedata = res.data
					} else {
						this.http.toast(res.msg)
					}
				})
			},
			classLableClick(item) { // 單击或双击
				if ((item.pid == 0 && item.is_haschild == 0) || (item.pid != 0 && item.is_haschild ==
						0)) {
					this.pid = item.id
				} else {
					this.pid = item.id
					this.getCateList()
				}
				this.topList.push(item)
				this.init()
			},
			back(item, index) { //点击顶部每一项返回上一分类
				this.pid = item.id
				if (this.pid == 0) {
					this.topList = [{
						name: "首頁",
						id: 0
					}]
					this.getCateList()
				} else {
					this.topList.splice(index + 1)
					this.getCateList()
				}
				this.init()
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/goods/Goodslist', 'POST', {
					page: page || 1,
					limit: _this.limit,
					shop_id: this.shop_id, //店鋪id
					shopclassify_id: this.pid ? this.pid : "",
					name: this.name
				}).then(res => {
					if (res.code == 1) {
						if (res.data.data.length && this.name) {
							this.jumpdetail(res.data.data[0].id)
						}
						this.name = ""
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottomt() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style>
	.margin_top15 {
		margin-top: 18rpx;
	}

	.baibtn {
		padding: 15rpx 20rpx;
	}

	.itemrighttab {
		padding: 18rpx 0;
		text-align: center;
		border-left: none;
		border-radius: 0 10rpx 10rpx 0;
	}

	.borderhui {
		border: 1rpx solid rgba(50, 60, 160, .1);
	}

	.tiebianarrow {
		height: 50rpx;
		background-color: #ffb800;
		width: 30rpx;
	}

	.main_size {
		font-size: 24rpx;
	}

	.itembox {
		margin-top: 15rpx;
		width: 150rpx;
		height: 120rpx;
		border: 1rpx solid #000;
		border-radius: 10rpx;
		font-size: 60rpx;
		font-weight: bold;
		box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(0, 0, 0, 0.16);
	}

	.itembox2 {
		margin-top: 15rpx;
		width: 150rpx;
		height: 120rpx;
		border: 1rpx solid #000;
		border-radius: 10rpx;
		font-size: 60rpx;
		font-weight: bold;
		box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(0, 0, 0, 0.16);
	}

	.delitem {
		background-color: #013447 !important;
		color: #fff !important;
	}

	.payTypeClass {
		text-align: center;
		font-size: 28rpx;
		font-weight: bold;
		padding: 40rpx 0;
		width: 150rpx;
	}

	.qxbtn {
		background-color: #004FA3;
		color: #fff;
		/* border: 2rpx solid #000; */
		font-size: 24rpx;
		font-weight: 900;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		letter-spacing: 3rpx;
	}
</style>